const express = require('express');
const router = express.Router();
const Leave = require('../database/models/message');



router.get('/', async function (req, res) {
    //获取留言数据
    const getleave = await Leave.findAll();
    console.log(getleave);
    //循环将留言内容放置于table数组
    const table = [];
    for (let i = 0; i < getleave.length; i++) {
        table.push(
            {
                account: getleave[i].dataValues.account,
                message: getleave[i].dataValues.message
            }
        )
    }
    return res.status(200).send(
        {
            good: "获取成功",
            data:
                table
        }
    )
});

module.exports = router;